package com.mgq.design.chainofresponsibility.c2;

import java.util.function.Function;
import java.util.function.UnaryOperator;

/**
 * <b>功能：</b>使用lambda简化<br>
 * <b>Copyright TCSL</b>
 * <li>版本&nbsp;&nbsp;&nbsp;&nbsp;修改日期&nbsp;&nbsp;&nbsp;&nbsp;部　　门&nbsp;&nbsp;&nbsp;&nbsp;作　者&nbsp;&nbsp;&nbsp;&nbsp;变更内容</li><hr>
 * <li>v1.0&nbsp;&nbsp;&nbsp;&nbsp;20220425&nbsp;&nbsp;营业后台&nbsp;&nbsp;&nbsp;&nbsp;马广奇&nbsp;&nbsp;&nbsp;&nbsp;创建类</li>
 * <br><br>
 *
 * @author 马广奇
 * @version 2022-04-25 18:06
 */
public class LambdaSimple {

    public static void main(String[] args) {
        //我们使用UnaryOperator来简化.UnaryOperator可以链接对象
        UnaryOperator<String> headerText = (String text) -> "From maguangqi " + text;
        UnaryOperator<String> spellCheck = (String text) -> text.replaceAll("labda", "lambda");

        //addThen()相当于链式处理 headerText的处理结果再交给spellCheck处理
        Function<String, String> pipeline = headerText.andThen(spellCheck);
        String result = pipeline.apply("Aren't labdas really sexy?!!");
        System.out.println(result);
    }
}
